package org.lee.strategy.app.event;

import org.lee.strategy.app.ICouponDiscount;

import java.math.BigDecimal;

/**
 * ZJCouponDiscount
 * 直减
 *
 * @author dralee
 * @date 2021-11-24 11:32:15
 **/
public class ZJCouponDiscount implements ICouponDiscount<Double> {

    /**
     * 直减
     * 1、使用商品价格减优惠价格
     * 2、最低支付金额1元
     *
     * @param couponInfo: 券折扣信息：直减、满减，折扣、N元购
     * @param skuPrice:   sku金额
     * @return
     */
    @Override
    public BigDecimal discountAmount(Double couponInfo, BigDecimal skuPrice) {
        BigDecimal discountAmount = skuPrice.subtract(new BigDecimal(couponInfo));
        if (discountAmount.compareTo(BigDecimal.ZERO) < 1) { // 最低1元
            return BigDecimal.ONE;
        }
        return discountAmount;
    }
}
